<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>couchdb.client.Database</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="couchdb-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="couchdb-module.html">Package&nbsp;couchdb</a> ::
        <a href="couchdb.client-module.html">Module&nbsp;client</a> ::
        Class&nbsp;Database
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Database</h1><p class="nomargin-top"></p>
<pre class="base-tree">
object --+
         |
        <strong class="uidshort">Database</strong>
</pre>

<hr />
<p>Representation of a database on a CouchDB server.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>server = Server(<span class="py-string">'http://localhost:5984/'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db = server.create(<span class="py-string">'python-tests'</span>)</pre>
<p>New documents can be added to the database using the <a href="couchdb.client.Database-class.html#create" class="link">create()</a> method:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>doc_id = db.create({<span class="py-string">'type'</span>: <span class="py-string">'Person'</span>, <span class="py-string">'name'</span>: <span class="py-string">'John Doe'</span>})</pre>
<p>This class provides a dictionary-like interface to databases: documents are
retrieved by their ID using item access</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>doc = db[doc_id]
<span class="py-prompt">&gt;&gt;&gt; </span>doc                 <span class="py-comment">#doctest: +ELLIPSIS</span>
<span class="py-output">&lt;Document '...'@... {...}&gt;</span></pre>
<p>Documents are represented as instances of the <a href="couchdb.client.Row-class.html" class="link">Row</a> class, which is
basically just a normal dictionary with the additional attributes <tt class="rst-docutils literal"><span class="pre">id</span></tt> and
<tt class="rst-docutils literal"><span class="pre">rev</span></tt>:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>doc.id, doc.rev     <span class="py-comment">#doctest: +ELLIPSIS</span>
<span class="py-output">('...', ...)</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span>doc[<span class="py-string">'type'</span>]
<span class="py-output">'Person'</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span>doc[<span class="py-string">'name'</span>]
<span class="py-output">'John Doe'</span></pre>
<p>To update an existing document, you use item access, too:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>doc[<span class="py-string">'name'</span>] = <span class="py-string">'Mary Jane'</span>
<span class="py-prompt">&gt;&gt;&gt; </span>db[doc.id] = doc</pre>
<p>The <a href="couchdb.client.Database-class.html#create" class="link">create()</a> method creates a document with a random ID generated by
CouchDB (which is not recommended). If you want to explicitly specify the
ID, you'd use item access just as with updating:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'JohnDoe'</span>] = {<span class="py-string">'type'</span>: <span class="py-string">'person'</span>, <span class="py-string">'name'</span>: <span class="py-string">'John Doe'</span>}</pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-string">'JohnDoe'</span> <span class="py-keyword">in</span> db
<span class="py-output">True</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span>len(db)
<span class="py-output">2</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">del</span> server[<span class="py-string">'python-tests'</span>]</pre>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Methods</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">uri</span>,
        <span class="summary-sig-arg">name</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>)</span><br />
      x.__init__(...) initializes x; see x.__class__.__doc__ for signature</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#__repr__" class="summary-sig-name">__repr__</a>(<span class="summary-sig-arg">self</span>)</span><br />
      repr(x)</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#__contains__" class="summary-sig-name">__contains__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>)</span><br />
      Return whether the database contains a document with the specified
ID.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__iter__"></a><span class="summary-sig-name">__iter__</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the IDs of all documents in the database.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__len__"></a><span class="summary-sig-name">__len__</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the number of documents in the database.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__nonzero__"></a><span class="summary-sig-name">__nonzero__</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return whether the database is available.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#__delitem__" class="summary-sig-name">__delitem__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>)</span><br />
      Remove the document with the specified ID from the database.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><a href="couchdb.client.Document-class.html" class="link">Document</a></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#__getitem__" class="summary-sig-name">__getitem__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>)</span><br />
      Return the document with the specified ID.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#__setitem__" class="summary-sig-name">__setitem__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>,
        <span class="summary-sig-arg">content</span>)</span><br />
      Create or update a document with the specified ID.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code class="link">unicode</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#create" class="summary-sig-name">create</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">data</span>)</span><br />
      Create a new document in the database with a random ID that is
generated by the server.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code class="link">bool</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#compact" class="summary-sig-name">compact</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Compact the database.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code class="link">str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#copy" class="summary-sig-name">copy</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">src</span>,
        <span class="summary-sig-arg">dest</span>)</span><br />
      Copy the given document to create a new document.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#delete" class="summary-sig-name">delete</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">doc</span>)</span><br />
      Delete the given document from the database.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><a href="couchdb.client.Document-class.html" class="link">Document</a></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#get" class="summary-sig-name">get</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>,
        <span class="summary-sig-arg">default</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">**options</span>)</span><br />
      Return the document with the specified ID.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#revisions" class="summary-sig-name">revisions</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>,
        <span class="summary-sig-arg">**options</span>)</span><br />
      Return all available revisions of the given document.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><tt class="rst-docutils literal"><span class="pre">dict</span></tt></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#info" class="summary-sig-name">info</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Return information about the database as a dictionary.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#delete_attachment" class="summary-sig-name">delete_attachment</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">doc</span>,
        <span class="summary-sig-arg">filename</span>)</span><br />
      Delete the specified attachment.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#get_attachment" class="summary-sig-name">get_attachment</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id_or_doc</span>,
        <span class="summary-sig-arg">filename</span>,
        <span class="summary-sig-arg">default</span>=<span class="summary-sig-default">None</span>)</span><br />
      Return an attachment from the specified doc id and filename.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#put_attachment" class="summary-sig-name">put_attachment</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">doc</span>,
        <span class="summary-sig-arg">content</span>,
        <span class="summary-sig-arg">filename</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">content_type</span>=<span class="summary-sig-default">None</span>)</span><br />
      Create or replace an attachment.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><a href="couchdb.client.ViewResults-class.html" class="link">ViewResults</a></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#query" class="summary-sig-name">query</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">map_fun</span>,
        <span class="summary-sig-arg">reduce_fun</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">language</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">javascript</code><code class="variable-quote">'</code></span>,
        <span class="summary-sig-arg">wrapper</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">**options</span>)</span><br />
      Execute an ad-hoc query (a &quot;temp view&quot;) against the database.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><tt class="rst-docutils literal"><span class="pre">list</span></tt></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#update" class="summary-sig-name">update</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">documents</span>,
        <span class="summary-sig-arg">**options</span>)</span><br />
      Perform a bulk update or insertion of the given documents using a
single HTTP request.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><a href="couchdb.client.ViewResults-class.html" class="link">ViewResults</a></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="couchdb.client.Database-class.html#view" class="summary-sig-name">view</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">name</span>,
        <span class="summary-sig-arg">wrapper</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">**options</span>)</span><br />
      Execute a predefined view.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Properties</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">basestring</span>
    </td><td class="summary">
        <a href="couchdb.client.Database-class.html#name" class="summary-name">name</a><br />
      The name of the database.
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Method Details</span></td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">uri</span>,
        <span class="sig-arg">name</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">http</span>=<span class="sig-default">None</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  <dl class="fields">
    <dt>Overrides:
        object.__init__
        <dd><em class="note">(inherited documentation)</em></dd>
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="__repr__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__repr__</span>(<span class="sig-arg">self</span>)</span>
    <br /><em class="fname">(Representation operator)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  repr(x)
  <dl class="fields">
    <dt>Overrides:
        object.__repr__
        <dd><em class="note">(inherited documentation)</em></dd>
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="__contains__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__contains__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>)</span>
    <br /><em class="fname">(In operator)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Return whether the database contains a document with the specified
ID.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> - the document ID</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd><code class="link">True</code> if a document with the ID exists, <code class="link">False</code> otherwise</dd>
  </dl>
</td></tr></table>
</div>
<a name="__delitem__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__delitem__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>)</span>
    <br /><em class="fname">(Index deletion operator)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Remove the document with the specified ID from the database.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> - the document ID</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="__getitem__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__getitem__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>)</span>
    <br /><em class="fname">(Indexing operator)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Return the document with the specified ID.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> - the document ID</li>
    </ul></dd>
    <dt>Returns: <a href="couchdb.client.Document-class.html" class="link">Document</a></dt>
        <dd>a <a href="couchdb.client.Row-class.html" class="link">Row</a> object representing the requested document</dd>
  </dl>
</td></tr></table>
</div>
<a name="__setitem__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__setitem__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>,
        <span class="sig-arg">content</span>)</span>
    <br /><em class="fname">(Index assignment operator)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Create or update a document with the specified ID.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> - the document ID</li>
        <li><strong class="pname"><code>content</code></strong> - the document content; either a plain dictionary for
new documents, or a <a href="couchdb.client.Row-class.html" class="link">Row</a> object for existing
documents</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="create"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">create</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">data</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Create a new document in the database with a random ID that is
generated by the server.</p>
<p>Note that it is generally better to avoid the <a href="couchdb.client.Database-class.html#create" class="link">create()</a> method and
instead generate document IDs on the client side. This is due to the
fact that the underlying HTTP <tt class="rst-docutils literal"><span class="pre">POST</span></tt> method is not idempotent, and
an automatic retry due to a problem somewhere on the networking stack
may cause multiple documents being created in the database.</p>
<p>To avoid such problems you can generate a UUID on the client side.
Python (since version 2.5) comes with a <tt class="rst-docutils literal"><span class="pre">uuid</span></tt> module that can be
used for this:</p>
<pre class="rst-literal-block">
from uuid import uuid4
doc_id = uuid4().hex
db[doc_id] = {'type': 'person', 'name': 'John Doe'}
</pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>data</code></strong> - the data to store in the document</li>
    </ul></dd>
    <dt>Returns: <code class="link">unicode</code></dt>
        <dd>the ID of the created document</dd>
  </dl>
</td></tr></table>
</div>
<a name="compact"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">compact</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Compact the database.</p>
<p>This will try to prune all revisions from the database.</p>
  <dl class="fields">
    <dt>Returns: <code class="link">bool</code></dt>
        <dd>a boolean to indicate whether the compaction was initiated
successfully</dd>
  </dl>
</td></tr></table>
</div>
<a name="copy"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">copy</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">src</span>,
        <span class="sig-arg">dest</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Copy the given document to create a new document.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>src</code></strong> - the ID of the document to copy, or a dictionary or
<a href="couchdb.client.Document-class.html" class="link">Document</a> object representing the source document.</li>
        <li><strong class="pname"><code>dest</code></strong> - either the destination document ID as string, or a
dictionary or <a href="couchdb.client.Document-class.html" class="link">Document</a> instance of the document that
should be overwritten.</li>
    </ul></dd>
    <dt>Returns: <code class="link">str</code></dt>
        <dd>the new revision of the destination document</dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        0.6
      </p>
</div></td></tr></table>
</div>
<a name="delete"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">delete</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">doc</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Delete the given document from the database.</p>
<p>Use this method in preference over <tt class="rst-docutils literal"><span class="pre">__del__</span></tt> to ensure you're
deleting the revision that you had previously retrieved. In the case
the document has been updated since it was retrieved, this method will
raise a <a href="couchdb.client.ResourceConflict-class.html" class="link">ResourceConflict</a> exception.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>server = Server(<span class="py-string">'http://localhost:5984/'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db = server.create(<span class="py-string">'python-tests'</span>)</pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>doc = dict(type=<span class="py-string">'Person'</span>, name=<span class="py-string">'John Doe'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'johndoe'</span>] = doc
<span class="py-prompt">&gt;&gt;&gt; </span>doc2 = db[<span class="py-string">'johndoe'</span>]
<span class="py-prompt">&gt;&gt;&gt; </span>doc2[<span class="py-string">'age'</span>] = 42
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'johndoe'</span>] = doc2
<span class="py-prompt">&gt;&gt;&gt; </span>db.delete(doc)
<span class="py-except">Traceback (most recent call last):</span>
<span class="py-except">  ...</span>
<span class="py-except">ResourceConflict: ('conflict', 'Document update conflict.')</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">del</span> server[<span class="py-string">'python-tests'</span>]</pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>doc</code></strong> - a dictionary or <a href="couchdb.client.Document-class.html" class="link">Document</a> object holding the document data</li>
    </ul></dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'><a href="couchdb.client.ResourceConflict-class.html">ResourceConflict</a></strong></code> - if the document was updated in the database</li>
    </ul></dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        0.4.1
      </p>
</div></td></tr></table>
</div>
<a name="get"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">get</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>,
        <span class="sig-arg">default</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">**options</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Return the document with the specified ID.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> - the document ID</li>
        <li><strong class="pname"><code>default</code></strong> - the default value to return when the document is not
found</li>
    </ul></dd>
    <dt>Returns: <a href="couchdb.client.Document-class.html" class="link">Document</a></dt>
        <dd>a <a href="couchdb.client.Row-class.html" class="link">Row</a> object representing the requested document, or <code class="link">None</code>
if no document with the ID was found</dd>
  </dl>
</td></tr></table>
</div>
<a name="revisions"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">revisions</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>,
        <span class="sig-arg">**options</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Return all available revisions of the given document.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> - the document ID</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>an iterator over Document objects, each a different revision,
in reverse chronological order, if any were found</dd>
  </dl>
</td></tr></table>
</div>
<a name="info"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">info</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Return information about the database as a dictionary.</p>
<p>The returned dictionary exactly corresponds to the JSON response to
a <tt class="rst-docutils literal"><span class="pre">GET</span></tt> request on the database URI.</p>
  <dl class="fields">
    <dt>Returns: <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">dict</span></tt></dt>
        <dd>a dictionary of database properties</dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        0.4
      </p>
</div></td></tr></table>
</div>
<a name="delete_attachment"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">delete_attachment</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">doc</span>,
        <span class="sig-arg">filename</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Delete the specified attachment.</p>
<p>Note that the provided <code class="link">doc</code> is required to have a <tt class="rst-docutils literal"><span class="pre">_rev</span></tt> field.
Thus, if the <code class="link">doc</code> is based on a view row, the view row would need to
include the <tt class="rst-docutils literal"><span class="pre">_rev</span></tt> field.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>doc</code></strong> - the dictionary or <a href="couchdb.client.Document-class.html" class="link">Document</a> object representing the
document that the attachment belongs to</li>
        <li><strong class="pname"><code>filename</code></strong> - the name of the attachment file</li>
    </ul></dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        0.4.1
      </p>
</div></td></tr></table>
</div>
<a name="get_attachment"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">get_attachment</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id_or_doc</span>,
        <span class="sig-arg">filename</span>,
        <span class="sig-arg">default</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Return an attachment from the specified doc id and filename.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id_or_doc</code></strong> - either a document ID or a dictionary or <a href="couchdb.client.Document-class.html" class="link">Document</a>
object representing the document that the attachment
belongs to</li>
        <li><strong class="pname"><code>filename</code></strong> - the name of the attachment file</li>
        <li><strong class="pname"><code>default</code></strong> - default value to return when the document or attachment
is not found</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>the content of the attachment as a string, or the value of the
<code class="link">default</code> argument if the attachment is not found</dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        0.4.1
      </p>
</div></td></tr></table>
</div>
<a name="put_attachment"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">put_attachment</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">doc</span>,
        <span class="sig-arg">content</span>,
        <span class="sig-arg">filename</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">content_type</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Create or replace an attachment.</p>
<p>Note that the provided <code class="link">doc</code> is required to have a <tt class="rst-docutils literal"><span class="pre">_rev</span></tt> field. Thus,
if the <code class="link">doc</code> is based on a view row, the view row would need to include
the <tt class="rst-docutils literal"><span class="pre">_rev</span></tt> field.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>doc</code></strong> - the dictionary or <a href="couchdb.client.Document-class.html" class="link">Document</a> object representing the
document that the attachment should be added to</li>
        <li><strong class="pname"><code>content</code></strong> - the content to upload, either a file-like object or
a string</li>
        <li><strong class="pname"><code>filename</code></strong> - the name of the attachment file; if omitted, this
function tries to get the filename from the file-like
object passed as the <code class="link">content</code> argument value</li>
        <li><strong class="pname"><code>content_type</code></strong> - content type of the attachment; if omitted, the
MIME type is guessed based on the file name
extension</li>
    </ul></dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        0.4.1
      </p>
</div></td></tr></table>
</div>
<a name="query"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">query</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">map_fun</span>,
        <span class="sig-arg">reduce_fun</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">language</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">javascript</code><code class="variable-quote">'</code></span>,
        <span class="sig-arg">wrapper</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">**options</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Execute an ad-hoc query (a &quot;temp view&quot;) against the database.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>server = Server(<span class="py-string">'http://localhost:5984/'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db = server.create(<span class="py-string">'python-tests'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'johndoe'</span>] = dict(type=<span class="py-string">'Person'</span>, name=<span class="py-string">'John Doe'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'maryjane'</span>] = dict(type=<span class="py-string">'Person'</span>, name=<span class="py-string">'Mary Jane'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'gotham'</span>] = dict(type=<span class="py-string">'City'</span>, name=<span class="py-string">'Gotham City'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>map_fun = <span class="py-string">'''function(doc) {</span>
<span class="py-more">... </span><span class="py-string">    if (doc.type == 'Person')</span>
<span class="py-more">... </span><span class="py-string">        emit(doc.name, null);</span>
<span class="py-more">... </span><span class="py-string">}'''</span>
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">for</span> row <span class="py-keyword">in</span> db.query(map_fun):
<span class="py-more">... </span>    <span class="py-keyword">print</span> row.key
<span class="py-output">John Doe</span>
<span class="py-output">Mary Jane</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">for</span> row <span class="py-keyword">in</span> db.query(map_fun, descending=True):
<span class="py-more">... </span>    <span class="py-keyword">print</span> row.key
<span class="py-output">Mary Jane</span>
<span class="py-output">John Doe</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">for</span> row <span class="py-keyword">in</span> db.query(map_fun, key=<span class="py-string">'John Doe'</span>):
<span class="py-more">... </span>    <span class="py-keyword">print</span> row.key
<span class="py-output">John Doe</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">del</span> server[<span class="py-string">'python-tests'</span>]</pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>map_fun</code></strong> - the code of the map function</li>
        <li><strong class="pname"><code>reduce_fun</code></strong> - the code of the reduce function (optional)</li>
        <li><strong class="pname"><code>language</code></strong> - the language of the functions, to determine which view
server to use</li>
        <li><strong class="pname"><code>wrapper</code></strong> - an optional callable that should be used to wrap the
result rows</li>
        <li><strong class="pname"><code>options</code></strong> - optional query string parameters</li>
    </ul></dd>
    <dt>Returns: <a href="couchdb.client.ViewResults-class.html" class="link">ViewResults</a></dt>
        <dd>the view reults</dd>
  </dl>
</td></tr></table>
</div>
<a name="update"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">update</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">documents</span>,
        <span class="sig-arg">**options</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Perform a bulk update or insertion of the given documents using a
single HTTP request.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>server = Server(<span class="py-string">'http://localhost:5984/'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db = server.create(<span class="py-string">'python-tests'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">for</span> doc <span class="py-keyword">in</span> db.update([
<span class="py-more">... </span>    Document(type=<span class="py-string">'Person'</span>, name=<span class="py-string">'John Doe'</span>),
<span class="py-more">... </span>    Document(type=<span class="py-string">'Person'</span>, name=<span class="py-string">'Mary Jane'</span>),
<span class="py-more">... </span>    Document(type=<span class="py-string">'City'</span>, name=<span class="py-string">'Gotham City'</span>)
<span class="py-more">... </span>]):
<span class="py-more">... </span>    <span class="py-keyword">print</span> repr(doc) <span class="py-comment">#doctest: +ELLIPSIS</span>
<span class="py-output">(True, '...', '...')</span>
<span class="py-output">(True, '...', '...')</span>
<span class="py-output">(True, '...', '...')</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">del</span> server[<span class="py-string">'python-tests'</span>]</pre>
<p>The return value of this method is a list containing a tuple for every
element in the <code class="link">documents</code> sequence. Each tuple is of the form
<tt class="rst-docutils literal"><span class="pre">(success,</span> <span class="pre">docid,</span> <span class="pre">rev_or_exc)</span></tt>, where <tt class="rst-docutils literal"><span class="pre">success</span></tt> is a boolean
indicating whether the update succeeded, <tt class="rst-docutils literal"><span class="pre">docid</span></tt> is the ID of the
document, and <tt class="rst-docutils literal"><span class="pre">rev_or_exc</span></tt> is either the new document revision, or
an exception instance (e.g. <a href="couchdb.client.ResourceConflict-class.html" class="link">ResourceConflict</a>) if the update failed.</p>
<p>If an object in the documents list is not a dictionary, this method
looks for an <tt class="rst-docutils literal"><span class="pre">items()</span></tt> method that can be used to convert the object
to a dictionary. Effectively this means you can also use this method
with <a href="couchdb.schema.Document-class.html" class="link">schema.Document</a> objects.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>documents</code></strong> - a sequence of dictionaries or <a href="couchdb.client.Document-class.html" class="link">Document</a> objects, or
objects providing a <tt class="rst-docutils literal"><span class="pre">items()</span></tt> method that can be
used to convert them to a dictionary</li>
    </ul></dd>
    <dt>Returns: <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">list</span></tt></dt>
        <dd>an iterable over the resulting documents</dd>
  </dl>
<div class="fields">      <p><strong>Since:</strong>
        version 0.2
      </p>
</div></td></tr></table>
</div>
<a name="view"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">view</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">name</span>,
        <span class="sig-arg">wrapper</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">**options</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Execute a predefined view.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>server = Server(<span class="py-string">'http://localhost:5984/'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db = server.create(<span class="py-string">'python-tests'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>db[<span class="py-string">'gotham'</span>] = dict(type=<span class="py-string">'City'</span>, name=<span class="py-string">'Gotham City'</span>)</pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">for</span> row <span class="py-keyword">in</span> db.view(<span class="py-string">'_all_docs'</span>):
<span class="py-more">... </span>    <span class="py-keyword">print</span> row.id
<span class="py-output">gotham</span></pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">del</span> server[<span class="py-string">'python-tests'</span>]</pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>name</code></strong> - the name of the view; for custom views, use the format
<tt class="rst-docutils literal"><span class="pre">design_docid/viewname</span></tt>, that is, the document ID of the
design document and the name of the view, separated by a
slash</li>
        <li><strong class="pname"><code>wrapper</code></strong> - an optional callable that should be used to wrap the
result rows</li>
        <li><strong class="pname"><code>options</code></strong> - optional query string parameters</li>
    </ul></dd>
    <dt>Returns: <a href="couchdb.client.ViewResults-class.html" class="link">ViewResults</a></dt>
        <dd>the view results</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== PROPERTY DETAILS ==================== -->
<a name="section-PropertyDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Property Details</span></td>
</tr>
</table>
<a name="name"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">name</h3>
  <p>The name of the database.</p>
<p>Note that this may require a request to the server unless the name has
already been cached by the <a href="couchdb.client.Database-class.html#info" class="link">info()</a> method.</p>
  <dl class="fields">
    <dt>Get Method:</dt>
    <dd class="value"><span class="summary-sig"><i>unreachable</i>.name(<span class="summary-sig-arg">self</span>)</span>
        - The name of the database.
    </dd>
    <dt>Type:</dt>
      <dd>basestring</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="couchdb-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Dec 14 15:25:33 2009
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
